package zFactory;

import org.eclipse.emf.common.util.EList;

import genArchi.Node;
import node1.AbstractTask;
import spu96a01.Spu96a01;
import spu96a01.Spu96a01Factory;
import bP.BP;

public class NodeSpu96a01 implements NodeInterface {

	/**
	 * Attributes
	 * */
	private BP busyperiod;
	private EList<AbstractTask> l_tasks;
	private boolean enableCreate;

	/**
	 * 
	 */
	public NodeSpu96a01(EList<AbstractTask> l_tasks, BP busyperiod, boolean enableCreate) 
	{
		this.l_tasks = l_tasks;
		this.busyperiod = busyperiod;
		this.enableCreate = enableCreate;
	}

	@Override
	public Node createNode() 
	{
		/* If the calling node attempts to create the node without list, return no object */
		if (l_tasks == null) return null;
		/**/
		Spu96a01 tech = Spu96a01Factory.eINSTANCE.createSpu96a01();

		/**/
		for (AbstractTask at : l_tasks) {

			/**/
			spu96a01.Task task = Spu96a01Factory.eINSTANCE.createTask();
			task.setId(at.getId());
			task.setWcet(at.getWcet());
			task.setPeriod(at.getPeriod());
			task.setDeadline(at.getDeadline());

			/**/
			tech.getTasks().add(task);
		}

		/**/
		tech.setBusyPeriod(this.busyperiod);

		/**/
		return tech;	
	}

	@Override
	public String getNodeName() 
	{
		return "spu96a01.impl.Spu96a01Impl";
	}

	@Override
	public void update(Node node) 
	{
		Spu96a01 tech = (Spu96a01)node;
		
		/**/
		if (this.busyperiod != null) tech.setBusyPeriod(this.busyperiod);
		
	}

	@Override
	public boolean isEnable() 
	{
		return this.enableCreate;
	}

}
